/**
 * 全局快捷键设置
 * 使用时，需在应用程序模块发出 ready 事件之后调用
 */
const { app, BrowserWindow, globalShortcut } = require('electron')
class Shortcut {
    regConsole (keys = 'Command+Control+Alt+F4') {
        globalShortcut.register(keys, function () {
            let myWindows = BrowserWindow.getAllWindows()
            myWindows.forEach(win => {
                if(win.webContents && !win.webContents.isDevToolsOpened()){
                    win.webContents.openDevTools({mode: 'detach'})
                }
            })
        })
    }
}
app.on('will-quit', function () {
    globalShortcut.unregisterAll()
})
module.exports = new Shortcut()
